package com.ydgk.dao;

import com.ydgk.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {

    @Insert("insert into user(unick,uemail,upass,regtime) values(#{unick},#{uemail},#{upass},#{regtime})")
    void insert(User user);

    @Select("select count(*) from user where uemail = #{uemail}")
    int findCountByUemail(String uemail);

    @Select("select count(*) from user where unick = #{unick}")
    int findCountByUnick(String unick);

    @Select("select count(*) from user where uphone = #{uphone}")
    int findCountByUphone(String uphone);

    @Select("select * from user where uemail = #{param1} and upass = #{param2}")
    User findByUemailAndUpass(String uemail, String upass);

    @Select("select * from user where unick = #{param1} and upass = #{param2}")
    User findByUnickAndUpass(String unick, String upass);

    @Select("select * from user where uphone = #{param1} and upass = #{param2}")
    User findByUphoneAndUpass(String uphone, String upass);

    @Select("select * from user where uid = #{uid}")
    User findById(Integer uid);

    @Update("update user set unick = #{unick}, uname = #{uname} , uphone = #{uphone} , upass = #{upass} , usex = #{usex} , ubirth  = #{ubirth} where uid = #{uid}")
    void updateById(User user);

    Integer findNCount();

    Integer findLMCount();
}
